<template>
  <div class="netease-login-wrapper">
    <!-- 背景层 -->
    <div class="login-bg">
      <!-- 背景图 -->
      <div class="bg-image"></div>
      <!-- 渐变遮罩 -->
      <div class="bg-gradient"></div>
    </div>
    
    <!-- 内容容器 -->
    <div class="login-content">
      <!-- 顶部Logo -->
      <div class="logo-header">
        <img src="/netease-icon.svg" alt="网易云音乐" class="logo-img">
      </div>
      
      <!-- 登录卡片 -->
      <div class="login-card">
        <!-- 登录方式切换 -->
        <div class="login-tabs">
          <div 
            class="tab-item" 
            :class="{ active: loginType === 'phone' }"
            @click="loginType = 'phone'"
          >
            手机号登录
          </div>
          <div 
            class="tab-item" 
            :class="{ active: loginType === 'password' }"
            @click="loginType = 'password'"
          >
            密码登录
          </div>
        </div>
        
        <!-- 手机号登录表单 -->
        <div v-if="loginType === 'phone'" class="login-form">
          <div class="form-group">
            <div class="input-wrapper">
              <span class="input-prefix">📱</span>
              <input 
                type="tel" 
                placeholder="请输入手机号" 
                v-model="phone"
                maxlength="11"
                class="form-input"
              >
            </div>
          </div>
          <div class="form-group">
            <div class="input-wrapper code-wrapper">
              <span class="input-prefix">🔒</span>
              <input 
                type="text" 
                placeholder="请输入验证码" 
                v-model="code"
                maxlength="6"
                class="form-input code-input"
              >
              <button 
                class="code-btn"
                @click="sendCode"
                :disabled="countdown > 0"
              >
                {{ countdown > 0 ? countdown + 's' : '获取验证码' }}
              </button>
            </div>
          </div>
        </div>
        
        <!-- 密码登录表单 -->
        <div v-else class="login-form">
          <div class="form-group">
            <div class="input-wrapper">
              <span class="input-prefix">👤</span>
              <input 
                type="text" 
                placeholder="手机号/邮箱/用户名" 
                v-model="username"
                class="form-input"
              >
            </div>
          </div>
          <div class="form-group">
            <div class="input-wrapper">
              <span class="input-prefix">🔒</span>
              <input 
                :type="showPassword ? 'text' : 'password'" 
                placeholder="请输入密码" 
                v-model="password"
                class="form-input"
              >
              <button 
                class="password-toggle"
                @click="togglePassword"
              >
                {{ showPassword ? '👁️' : '👁️‍🗨️' }}
              </button>
            </div>
          </div>
          <div class="form-options">
            <label class="remember-checkbox">
              <input type="checkbox" v-model="remember">
              <span>自动登录</span>
            </label>
            <a href="#" class="forgot-password">忘记密码</a>
          </div>
        </div>
        
        <!-- 登录按钮 -->
        <button 
          class="login-button"
          :disabled="isLoading"
          @click="handleLogin"
        >
          <span v-if="isLoading" class="loading-spinner"></span>
          {{ isLoading ? '登录中...' : '登录' }}
        </button>
        
        <!-- 其他登录方式 -->
        <div class="other-login">
          <div class="divider">
            <span>其他登录方式</span>
          </div>
          <div class="third-party-login">
            <button class="third-party-btn" @click="thirdLogin('微信')">
              <img src="/wechat-icon.svg" alt="微信登录" class="third-icon">
            </button>
            <button class="third-party-btn" @click="thirdLogin('QQ')">
              <img src="/qq-icon.svg" alt="QQ登录" class="third-icon">
            </button>
            <button class="third-party-btn" @click="thirdLogin('微博')">
              <img src="/netease-icon.svg" alt="微博登录" class="third-icon">
            </button>
          </div>
        </div>
        
        <!-- 注册链接 -->
        <div class="register-section">
          <span>还没有账号？</span>
          <a href="#" class="register-link">立即注册</a>
        </div>
      </div>
      
      <!-- 底部版权信息 -->
      <div class="login-footer">
        <div class="footer-links">
          <a href="#">关于网易云音乐</a>
          <span>|</span>
          <a href="#">服务条款</a>
          <span>|</span>
          <a href="#">隐私政策</a>
          <span>|</span>
          <a href="#">联系我们</a>
          <span>|</span>
          <a href="#">帮助中心</a>
        </div>
        <p class="copyright">Copyright © 2024 NetEase Corporation. All Rights Reserved.</p>
      </div>
    </div>
    
    <!-- 黑胶唱片装饰 -->
    <div class="vinyl-record"></div>
  </div>
</template>

<script>
export default {
  name: 'App',
  data() {
    return {
      // 登录类型
      loginType: 'phone',
      // 表单数据
      phone: '',
      code: '',
      username: '',
      password: '',
      // 状态
      showPassword: false,
      remember: false,
      isLoading: false,
      countdown: 0,
      timer: null
    }
  },
  methods: {
    // 发送验证码
    sendCode() {
      if (!/^1[3-9]\d{9}$/.test(this.phone)) {
        alert('请输入正确的手机号')
        return
      }
      
      // 开始倒计时
      this.countdown = 60
      this.timer = setInterval(() => {
        this.countdown--
        if (this.countdown <= 0) {
          clearInterval(this.timer)
        }
      }, 1000)
      
      alert(`验证码已发送至 ${this.phone}`)
    },
    
    // 切换密码显示
    togglePassword() {
      this.showPassword = !this.showPassword
    },
    
    // 第三方登录
    thirdLogin(type) {
      alert(`使用${type}登录`)
    },
    
    // 登录处理
    handleLogin() {
      // 验证
      if (this.loginType === 'phone') {
        if (!this.phone) {
          alert('请输入手机号')
          return
        }
        if (!/^1[3-9]\d{9}$/.test(this.phone)) {
          alert('请输入正确的手机号')
          return
        }
        if (!this.code) {
          alert('请输入验证码')
          return
        }
      } else {
        if (!this.username) {
          alert('请输入账号')
          return
        }
        if (!this.password) {
          alert('请输入密码')
          return
        }
      }
      
      // 模拟登录
      this.isLoading = true
      setTimeout(() => {
        this.isLoading = false
        alert('登录成功')
      }, 1500)
    }
  },
  
  // 清理定时器
  beforeUnmount() {
    if (this.timer) {
      clearInterval(this.timer)
    }
  }
}
</script>

<style>
/* 全局样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  color: #333;
  background-color: #f5f5f5;
}

/* 登录页面容器 */
.netease-login-wrapper {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* 背景层 */
.login-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
}

.bg-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url('https://p3.music.126.net/8Z1Y0t3rA-kKk7o7p2t7HQ==/109951166966934812.jpg');
  background-size: cover;
  background-position: center;
  filter: brightness(0.3);
}

.bg-gradient {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.5) 100%);
}

/* 内容容器 */
.login-content {
  position: relative;
  height: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* 顶部Logo */
.logo-header {
  padding-left: 40px;
}

.logo-img {
  width: 170px;
  height: auto;
}

/* 登录卡片 */
.login-card {
  position: absolute;
  top: 50%;
  right: 100px;
  transform: translateY(-50%);
  width: 410px;
  background-color: white;
  border-radius: 12px;
  padding: 40px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

/* 登录标签切换 */
.login-tabs {
  display: flex;
  margin-bottom: 30px;
  border-bottom: 1px solid #f0f0f0;
}

.tab-item {
  padding: 0 20px 15px;
  font-size: 16px;
  font-weight: 500;
  color: #999;
  cursor: pointer;
  transition: all 0.3s;
  position: relative;
}

.tab-item.active {
  color: #e60023;
}

.tab-item.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 20px;
  right: 20px;
  height: 2px;
  background-color: #e60023;
}

/* 表单样式 */
.login-form {
  margin-bottom: 20px;
}

.form-group {
  margin-bottom: 20px;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  border: 1px solid #e6e6e6;
  border-radius: 6px;
  transition: all 0.3s;
}

.input-wrapper:focus-within {
  border-color: #e60023;
  box-shadow: 0 0 0 2px rgba(230, 0, 35, 0.1);
}

.input-prefix {
  padding: 0 15px;
  font-size: 18px;
  color: #999;
}

.form-input {
  flex: 1;
  height: 48px;
  padding: 0;
  border: none;
  outline: none;
  font-size: 14px;
}

/* 验证码输入框 */
.code-wrapper {
  display: flex;
  align-items: center;
}

.code-input {
  flex: 1;
}

.code-btn {
  width: 120px;
  height: 32px;
  margin-right: 10px;
  background-color: #f5f5f5;
  border: 1px solid #e6e6e6;
  border-radius: 4px;
  color: #333;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.3s;
}

.code-btn:hover:not(:disabled) {
  background-color: #e6e6e6;
}

.code-btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  color: #999;
}

/* 密码切换按钮 */
.password-toggle {
  padding: 0 15px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
}

/* 表单选项 */
.form-options {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  font-size: 14px;
}

.remember-checkbox {
  display: flex;
  align-items: center;
  color: #666;
  cursor: pointer;
}

.remember-checkbox input {
  margin-right: 6px;
}

.forgot-password {
  color: #666;
  text-decoration: none;
}

.forgot-password:hover {
  color: #e60023;
}

/* 登录按钮 */
.login-button {
  width: 100%;
  height: 48px;
  background: linear-gradient(135deg, #e60023 0%, #c6001f 100%);
  border: none;
  border-radius: 24px;
  font-size: 16px;
  font-weight: 500;
  color: white;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(230, 0, 35, 0.3);
}

.login-button:disabled {
  cursor: not-allowed;
  opacity: 0.8;
}

/* 加载动画 */
.loading-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 0.8s linear infinite;
  margin-right: 8px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* 其他登录方式 */
.other-login {
  margin-top: 30px;
}

.divider {
  position: relative;
  margin-bottom: 30px;
  text-align: center;
  font-size: 14px;
  color: #999;
}

.divider::before,
.divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 130px;
  height: 1px;
  background-color: #e6e6e6;
}

.divider::before {
  left: 0;
}

.divider::after {
  right: 0;
}

/* 第三方登录 */
.third-party-login {
  display: flex;
  justify-content: center;
  gap: 30px;
}

.third-party-btn {
  width: 48px;
  height: 48px;
  background: none;
  border: none;
  cursor: pointer;
  transition: transform 0.3s;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.third-party-btn:hover {
  transform: scale(1.1);
  background-color: #f5f5f5;
}

.third-icon {
  width: 36px;
  height: 36px;
  transition: transform 0.3s;
}

.third-party-btn:hover .third-icon {
  transform: scale(1.05);
}

/* 注册链接 */
.register-section {
  margin-top: 30px;
  text-align: center;
  font-size: 14px;
  color: #666;
}

.register-link {
  color: #e60023;
  text-decoration: none;
  margin-left: 5px;
}

.register-link:hover {
  text-decoration: underline;
}

/* 底部版权信息 */
.login-footer {
  text-align: center;
  padding-bottom: 30px;
  color: rgba(255, 255, 255, 0.6);
  font-size: 12px;
}

.footer-links {
  margin-bottom: 10px;
}

.footer-links a {
  color: rgba(255, 255, 255, 0.6);
  text-decoration: none;
  margin: 0 10px;
}

.footer-links a:hover {
  color: white;
  text-decoration: underline;
}

.footer-links span {
  margin: 0 5px;
  color: rgba(255, 255, 255, 0.3);
}

.copyright {
  margin: 0;
}

/* 贾斯丁比伯黑胶唱片装饰 */
.vinyl-record {
  position: absolute;
  top: 50%;
  left: 15%;
  transform: translateY(-50%);
  width: 400px;
  height: 400px;
  background-image: url('https://images.unsplash.com/photo-1517841905240-472988babdf9?ixlib=rb-1.2.1&auto=format&fit=crop&w=800&q=80');
  background-size: cover;
  background-position: center;
  border-radius: 50%;
  opacity: 1;
  animation: rotate 20s linear infinite;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
  z-index: 1;
  overflow: hidden;
}

.vinyl-record::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100px;
  height: 100px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
}

.vinyl-record::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
}

@keyframes rotate {
  from {
    transform: translateY(-50%) rotate(0deg);
  }
  to {
    transform: translateY(-50%) rotate(360deg);
  }
}

/* 响应式设计 */
@media (max-width: 1200px) {
  .login-card {
    right: 50px;
  }
  
  .vinyl-record {
    left: 5%;
    width: 350px;
    height: 350px;
  }
}

@media (max-width: 992px) {
  .login-card {
    position: static;
    transform: none;
    width: 90%;
    max-width: 410px;
    margin: 50px auto;
  }
  
  .vinyl-record {
    display: none;
  }
  
  .logo-header {
    text-align: center;
    padding-left: 0;
  }
}

@media (max-width: 576px) {
  .login-content {
    padding: 20px;
  }
  
  .login-card {
    padding: 30px 20px;
  }
  
  .divider::before,
  .divider::after {
    width: 100px;
  }
  
  .third-party-login {
    gap: 20px;
  }
}
</style>